﻿#region Using namespaces

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;

using BOL.Apps.GeneNetworkBrowser.Analysis;

#endregion

namespace BOL.Apps.GeneNetworkBrowser.ViewModels
{
    public sealed class ProjectTreeViewItemViewModel : TreeViewItemViewModel
    {
        #region TreeViewItemViewModel implementation

        private ObservableCollection<Network> _networks;
        private ObservableCollection<IAnalysis> _analyses;

        public ObservableCollection<Network> Networks { get { return _networks; } }
        public ObservableCollection<IAnalysis> Analyses { get { return _analyses; } }

        public ProjectTreeViewItemViewModel(string title, IEnumerable<Network> networks, IEnumerable<IAnalysis> analyses)
            : base(null, true)
        {
            _networks = new ObservableCollection<Network>(networks);
            _analyses = new ObservableCollection<IAnalysis>(analyses);
            _title = title;
        }

        public ProjectTreeViewItemViewModel(string title)
            : this(title, new Network[0], new IAnalysis[0]) { }

        protected override void LoadChildren()
        {
            base.Children.Clear();
            base.Children.Add(new NetworksTreeViewItemViewModel(_networks, this));
            base.Children.Add(new AnalysesTreeViewItemViewModel(_analyses, this));
        }

        public void AddNetwork(Network network)
        {
            _networks.Add(network);
            LoadChildren();
        }

        public void AddAnalysis(IAnalysis analysis)
        {
            _analyses.Add(analysis);
            LoadChildren();
        }


        #endregion
    }
}
